package MyGui;

import java.awt.Component;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.JFrame;

/**
 * The class <code>MyDlgFrame</code> offers some basic helper functionality for
 * dialog frames.
 *
 */
public class MyDlgFrame extends JFrame {
    public static final int GAP = 6;
    public static GridBagLayout gridBagLayout = new GridBagLayout();

    protected MainFrame mainFrame;

    /**
     * Creates a new, initially invisible <code>MyDlgFrame</code> with the
     * specified title.
     *
     * @param parent  the parent for the frame
     * @param title   the title for the frame
     *
     * @see Component#setSize
     * @see Component#setVisible
     */
    public MyDlgFrame(MainFrame parent, String title) {
        super(title);
        mainFrame = parent;
        setLocation(200,200);
        setIconImage(GuiConst.ipadIcon.getImage());
    }

    /**
     * Adds a given component to a given container with given parameters
     */
    protected void add(Container container, Component component,
        int gridx, int gridy, int gridwidth, int gridheight,
        int weightx, int weighty, int anchor, int fill,
        int top, int left, int bottom, int right) {
        gbc.gridx      = gridx;
        gbc.gridy      = gridy;
        gbc.gridwidth  = gridwidth;
        gbc.gridheight = gridheight;
        gbc.weightx    = weightx;
        gbc.weighty    = weighty;
        gbc.anchor     = anchor;
        gbc.fill       = fill;
        gbc.insets.top    = top;
        gbc.insets.left   = left;
        gbc.insets.bottom = bottom;
        gbc.insets.right  = right;
        container.add(component, gbc);
    }

    protected static GridBagConstraints gbc = new GridBagConstraints(
        0, 0, 1, 1, 0, 0,
        GridBagConstraints.CENTER, GridBagConstraints.BOTH,
        new Insets(0, 0, 0, 0), 0, 0);
}